home *** CD-ROM | disk | FTP | other *** search
- Path: noc.netcom.net!news
- From: Tarang Deshpande <tarang@willows.com>
- Newsgroups: comp.lang.c
- Subject: Re: Nee help with a string and temp string
- Date: Mon, 15 Apr 1996 13:00:03 -0700
- Organization: NETCOM Network Operations
- Message-ID: <3172AAC3.2D5D@willows.com>
- References: <316C72CC.763A@cloudnet.com> <316DB246.74FB@willows.com> <829411539snz@genesis.demon.co.uk>
- NNTP-Posting-Host: daffy.willows.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB2 (Win95; I)
-
- Lawrence Kirby wrote:
- > Wrong. strncpy() always writes exactly the number of characters you specify
- > to the target buffer. It does not guarantee that the result is a string i.e.
- > null character terminated and is an oddity in the standard string library.
- > In this case it simply corresponds to:
- >
- > Bcard[0] = 'B';
- >
-
- Lawrence is abolutly right I didn't look at the code carefully enough
- and read strncpy as strcpy even though I typed strncpy. I use strncpy
- so rarely that I just had it in my head that is was strcpy. However
- I still say the simplest, though costly, solution is to memset the
- buffer to 0.
-